package com.hitgo.soccer.config;

import java.util.HashMap;

import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;

public class PropsConfig
{
	public int id;
	
	public int cash_type;	
	public int buy_money;
	public int max_package;


	public static HashMap<Integer, PropsConfig> propsConfigs = new HashMap<Integer, PropsConfig>();
	public static void loadConfig(String configFile)
	{
		if (configFile == null || configFile.isEmpty())
			return;
			
		// 获取文档的根元素，赋值给rootElement变量
		Element rootElement = ConfigUtil.GetRootElement(configFile);
		if(rootElement == null)
			return ;
		
		NodeList nodeList = rootElement.getElementsByTagName("RECORD");
		for(int nIndex = 0; nIndex < nodeList.getLength(); nIndex++)
		{
			Node nodeItem = nodeList.item(nIndex);
			if(nodeItem == null)
				continue ;
			PropsConfig pConfig = new PropsConfig();
			pConfig.id = ConfigUtil.GetAttributeIntValue(nodeItem, "id");
			pConfig.cash_type = (short) ConfigUtil.GetAttributeIntValue(nodeItem, "cash_type");
			
			pConfig.buy_money = ConfigUtil.GetAttributeIntValue(nodeItem, "buy_money");
			pConfig.max_package = ConfigUtil.GetAttributeIntValue(nodeItem, "max_package");
			
			propsConfigs.put(pConfig.id, pConfig);
		}
	}

	public static PropsConfig getPropsConfig(int propsID)
	{
		return propsConfigs.get(propsID);
	}
}
